/***************************************************************************
 *   Copyright (C) 2007 by Alexandre Masselot,,,   *
 *   alex@alex-laptop   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef AMINOACID_H
#define AMINOACID_H
#include "peptide.h"
#include <iostream>
#include <assert.h>
/**
	@author Alexandre Masselot,,, <alex@alex-laptop>
 */
using namespace std;
namespace bol{
class AminoAcid{
  friend class Peptide;
  public:
#ifndef _MSC_VER // MSVC has strange static const
    static const unsigned char CHAR_NTERM_PEPTIDE=27;
    static const unsigned char CHAR_CTERM_PEPTIDE=28;
#else
    static const unsigned char CHAR_NTERM_PEPTIDE;
    static const unsigned char CHAR_CTERM_PEPTIDE;
#endif
    static double *s_char2mass;
    AminoAcid(){};

    ~AminoAcid(){};

    /**
     * initialize the reduced char mass (unmodified) values
     */
    static void initChar2mass();

    /**
     *
     * @param c an aminoacid (original or modified), reduced
     * @return the amino acid mass
     */
    static double char2mass(const unsigned char c){
      return s_char2mass[static_cast<int>(c)];
    }

    /**
     * set a mass for a reduced (potentially modified) amino acid
     * @param c the char (starting from 1)
     * @param m the mass
     */
    static void setChar2mass(const unsigned char c, const double m){
      initChar2mass();
      s_char2mass[static_cast<int>(c)]=m;
    }

    /**
     *
     * @param AA
     * @return the reduced code associated to a character amino acid ('A'->'Z', '^', '$'...)
     */
    static unsigned char aa2reduced(const unsigned char AA);
    static unsigned char reduced2aa(const unsigned char c);

}; // class AminoAcid


} // namespace bol

#endif
